<?php
 class Core_Business_Rule extends Core_Business_Abstract{
	private $_id;
	private $_name;
	const ADMIN="admin";
	const Guest="guest";
	const Customer="customer";
	const Trainer="trainer";
	
	
	
	public function getId() {return $this->_id;}
	public function setId($value) {
		
			$this->_id=$value;
		//else
		//	throw new Exception("Property value for object ".__CLASS__.", property ".__METHOD__);
	}
	
	public function getName() {return $this->_name;}
	public function setName($value) {
		//if(is_string($value))
			$this->_name = $value;
		//else
		//	throw new Exception("Property value for object ".__CLASS__.", property ".__METHOD__);
	}
	
	public static function getRules() {
		$mapper = new Core_Data_Mappers_Rule();
		$rules = $mapper->fetchAll();
		return $rules;
	}
	public static function getRuleById($id) {
		$map = new Core_Data_Mappers_Rule();
		$rule = $map->find($id);
		if($rule instanceof Core_Business_Rule)
			return $rule;
		else 
			return null;
		
	}
	public static function getRuleByName($name) {
		$map = new Core_Data_Mappers_Rule();
		$rule = $map->fetchAll(array("name = ?"=>$name),1);
		
		if(current($rule) instanceof Core_Business_Rule)
			return current($rule);
		else 
			return null;
		
	}
	
}
?>